__list = {}

class Error(Exception): pass

class Abstract(object):

  def __init__(self, handler, type):
    self.handler = handler
    self.type = type

  def delete(self, key):
    raise Error('session not setup')

  def get(self, key, default=None):
    raise Error('session not setup')

  def set(self, key, value):
    raise Error('session not setup')

  def save(self):
    raise Error('session not setup')

def get(handler, type='default'):
  global __list
  if type in __list:
    (module, args, kwargs) = __list[type]
    return module(handler, type, *args, **kwargs)
  else:
    return Abstract(handler, type)

def set(module, type, *args, **kwargs):
  global __list
  __list[type] = (module, args, kwargs)
